package cn.toolck.service.impl;

import cn.toolck.dao.LagouUserInfoDao;
import cn.toolck.pojo.LagouUserInfo;
import cn.toolck.user.service.LagouUserInfoService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;

import java.util.Optional;

/**
 * @ClassName LagouUserInfoServiceImpl
 * @Description TODO
 * @Author Toolck Rin
 * @Date 2021/5/19 16:46
 * @Version 1.0
 **/
@Service
public class LagouUserInfoServiceImpl implements LagouUserInfoService {
    @Autowired
    private LagouUserInfoDao lagouUserInfoDao;
    @Override
    public LagouUserInfo insert(String email, String password) {
        LagouUserInfo lagouUserInfo = new LagouUserInfo();
        lagouUserInfo.setEmail(email);
        lagouUserInfo.setPassword(password);
        return lagouUserInfoDao.save(lagouUserInfo);
    }

    @Override
    public Optional<LagouUserInfo> findOneByEmail(String email) {
        LagouUserInfo lagouUserInfo = new LagouUserInfo();
        lagouUserInfo.setEmail(email);
        Example<LagouUserInfo> example = Example.of(lagouUserInfo);
        return lagouUserInfoDao.findOne(example);
    }
}
